{% extends 'base.html' %}

{% block title %}餐厅列表 - 外卖订餐系统{% endblock %}

{% block content %}
<div class="container mt-4">
    <h2 class="mb-4">餐厅列表</h2>
    
    <div class="row">
        {% for restaurant in restaurants %}
        <div class="col-md-4 mb-4">
            <div class="card h-100">
                {% if restaurant.image %}
                    <img src="{{ restaurant.image.url }}" class="card-img-top" alt="{{ restaurant.name }}">
                {% else %}
                    <div class="card-img-top bg-light text-center py-5">
                        <i class="fas fa-utensils fa-3x text-muted"></i>
                    </div>
                {% endif %}
                <div class="card-body">
                    <h5 class="card-title">{{ restaurant.name }}</h5>
                    <p class="card-text">{{ restaurant.description|truncatewords:20 }}</p>
                    <div class="d-flex justify-content-between align-items-center">
                        <div>
                            <span class="badge bg-primary">评分: {{ restaurant.rating|default:"暂无" }}</span>
                            {% if restaurant.is_open %}
                                <span class="badge bg-success">营业中</span>
                            {% else %}
                                <span class="badge bg-secondary">已打烊</span>
                            {% endif %}
                        </div>
                    </div>
                </div>
                <div class="card-footer bg-transparent">
                    <a href="{% url 'order:restaurant_detail' restaurant.id %}" class="btn btn-primary w-100">查看详情</a>
                </div>
            </div>
        </div>
        {% empty %}
        <div class="col-12">
            <div class="alert alert-info" role="alert">
                暂时没有可用的餐厅。
            </div>
        </div>
        {% endfor %}
    </div>
</div>
{% endblock %}

{% block extra_css %}
<style>
    .card {
        transition: transform 0.2s;
    }
    .card:hover {
        transform: translateY(-5px);
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    }
    .card-img-top {
        height: 200px;
        object-fit: cover;
    }
</style>
{% endblock %}
